/**
 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package org.openwork.portlet.skillmanagement.model.impl;

import java.util.ArrayList;
import java.util.List;

import org.openwork.portlet.skillmanagement.model.Skill;
import org.openwork.portlet.skillmanagement.model.SkillCategory;
import org.openwork.portlet.skillmanagement.service.SkillLocalServiceUtil;

import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.model.Group;
import com.liferay.portal.model.User;
import com.liferay.portal.service.GroupLocalServiceUtil;
import com.liferay.portal.service.UserLocalServiceUtil;

/**
 * <a href="SkillCategoryImpl.java.html"><b><i>View Source</i></b></a>
 *
 * @author samuelgmartinez
 */
public class SkillCategoryImpl extends SkillCategoryModelImpl
	implements SkillCategory {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -7829082671247584445L;
	public static Log log = LogFactoryUtil.getLog(SkillCategoryImpl.class);
	
	public SkillCategoryImpl() {
	}
	
	public List<Skill> getSkills() {
		try {
			return SkillLocalServiceUtil.searchByCategoryId(getId());
		}
		catch (Exception e) {
			if (log.isWarnEnabled()) {
				log.warn("Unable to get skills for category " + getId());
			}
		}

		return new ArrayList<Skill>();
	}
	
	public Group getGroup() {
		try {
			return GroupLocalServiceUtil.getGroup(getGroupId());
		}
		catch (Exception e) {
			if (log.isWarnEnabled()) {
				log.warn("Unable to get group for skillCategory" + getId());
			}
		}

		return null;
	}
	
	public User getUser() {
		try {
			return UserLocalServiceUtil.getUser(getUserId());
		}
		catch (Exception e) {
			if (log.isWarnEnabled()) {
				log.warn("Unable to get user for skillCategory" + getId());
			}
		}

		return null;
	}

}